<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>数据字典管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	$(document).ready(function() {
		layui.use(['laypage', 'form','table'], function(){
			var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
			form.render();
			var laypage = layui.laypage;
			laypage.render({elem:'pageDiv',
				count: ${page.count}, //数据总数，从服务端得到
				curr:${page.pageNo},
				limit:30,
				layout: ['prev', 'page', 'next', 'count'],
				jump: function(obj, first){
				//obj包含了当前分页的所有参数，比如：
				 // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
				 // console.log(obj.limit); //得到每页显示的条数
				
				//首次不执行
					if(!first){
						$("#firstPage").val(false);
						page(obj.curr,obj.limit);
					}
				}
			});
			var table = layui.table;
			table.init('dictTable',{limit:30});
		}); 
	});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
		<li class="layui-this"><a href="${ctx}/sys/dictcode/dictCode/">数据字典列表</a></li>
		<shiro:hasPermission name="sys:dictcode:dictCode:edit"><li><a href="${ctx}/sys/dictcode/dictCode/form?sort=10&version=1">数据字典添加</a></li></shiro:hasPermission>
		</ul>
	</div>
	<form:form id="searchForm" modelAttribute="dictCode" action="${ctx}/sys/dictcode/dictCode/" method="post" class="layui-form">
		<blockquote class="layui-elem-quote quoteBox">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		
		<div class="layui-inline">
			<label class="layui-form-label">标签名：</label>
			<div class="layui-input-block">
				<form:input path="label" htmlEscape="false" maxlength="100" class="layui-input"/>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">类型：</label>
			<div class="layui-input-block">
				<form:select path="type" class="layui-input">
					<form:option value="" label="---请选择---"/>
					<form:options items="${typeList}" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">版本号：</label>
			<div class="layui-input-block">
				<form:input path="version" htmlEscape="false" maxlength="10" class="layui-input"/>
			</div>
		</div>
		<div class="layui-inline">
			&nbsp;&nbsp;<input id="btnSubmit" class="layui-btn search_btn" type="submit" value="查询" />
		</div>
		</blockquote>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="layui-table" lay-filter="dictTable">
		<thead>
			<tr>
				<th lay-data="{field:'value', minWidth:100}">数据值</th>
				<th lay-data="{field:'lable', minWidth:100}">标签名</th>
				<th lay-data="{field:'type', minWidth:150}">类型</th>
				<th lay-data="{field:'value', minWidth:120}">描述</th>
				<th lay-data="{field:'sort', minWidth:70}">排序（升序）</th>
				<th lay-data="{field:'vision', minWidth:100}">版本号</th>
				<th lay-data="{field:'time', minWidth:150}">更新时间</th>
<!-- 				<th>备注信息</th> -->
				<shiro:hasPermission name="sys:dictcode:dictCode:edit">
				<th lay-data="{field:'flag', minWidth:170}">操作</th>
				</shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="dictCode">
			<tr>
				<td><a class="layui-blue" href="${ctx}/sys/dictcode/dictCode/form?id=${dictCode.id}">
					${dictCode.value}
				</a></td>
				<td>
					${dictCode.label}
				</td>
				<td>
					<a class="layui-blue" href="javascript:" onclick="$('#type').val('${dictCode.type}');$('#searchForm').submit();return false;">${dictCode.type}</a>
				</td>
				<td>
					${dictCode.description}
				</td>
				<td>
					${dictCode.sort}
				</td>
				<td>
					${dictCode.version}
				</td>
				<td>
					<fmt:formatDate value="${dictCode.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
<!-- 				<td> -->
<%-- 					${dictCode.remarks} --%>
<!-- 				</td> -->
				<shiro:hasPermission name="sys:dictcode:dictCode:edit"><td>
					<c:if test="${dictCode.isNewVersion eq 0 }">
						<a class="layui-btn layui-btn-xs" lay-event="edit" href="${ctx}/sys/dictcode/dictCode/form?id=${dictCode.id}">修改</a>
						<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" href="${ctx}/sys/dictcode/dictCode//delete?id=${dictCode.id}&type=${dict.type}" onclick="return confirmx('确认要删除该数据字典吗？', this.href)">删除</a>
						<a class="layui-btn layui-btn-normal layui-btn-xs" href="<c:url value='${fns:getAdminPath()}/sys/dictcode/dictCode/form?type=${dictCode.type}&sort=${dictCode.sort+10}&version=${dictCode.version}'><c:param name='description' value='${dict.description}'/></c:url>">添加键值</a>					
					</c:if>
<%-- 					<c:if test="${dictCode.isNewVersion ne 0 }"> --%>
<!-- 						<a style="color:#000">修改</a> -->
<!-- 						<a style="color:#000">删除</a> -->
<!-- 						<a style="color:#000">添加键值</a>					 -->
<%-- 					</c:if> --%>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div id="pageDiv" class="pagination layui-elem-field layui-field-title">${page}</div>
</body>
</html>